clear

disp 'Data in preparation...';
name='syndata';

cdbklen=5;
cdbksize=32;
cdbk=load(strcat(name,num2str(cdbklen),'_',num2str(cdbksize),'.cdk'));
cdbk=truncwidth(cdbklen,cdbk);
cdbk_dist_matrix=dist(cdbk');  % Euclidean distance matrix for the codewords

origdata=load(strcat('norm_',name,'.txt'));
[num_ts,len_ts]=size(origdata)
num_seg = len_ts/cdbklen

encoded_data=load(strcat(name,num2str(cdbklen),'_',num2str(cdbksize),'.his'));
encoded_data=encoded_data+1;
encoded_data=truncwidth(num_seg,encoded_data);
datarec=load(strcat(name,num2str(cdbklen),'_',num2str(cdbksize),'.rec'));
datarec=truncwidth( size(origdata,2),datarec);

roughdist=zeros(num_ts);
for i= 1:num_ts
    for j=i+1:num_ts
        for k=1:num_seg
            roughdist(i,j)=roughdist(i,j)+cdbk_dist_matrix(encoded_data(i,k),encoded_data(j,k))*cdbk_dist_matrix(encoded_data(i,k),encoded_data(j,k));
        end
        roughdist(i,j)=sqrt(roughdist(i,j));
    end
end
roughdist=roughdist+roughdist';
dist_euc=dist(origdata');   % Euclidean distance matrix
save syndata.mat;
clear;


